//
//  LGSportTrainItemCell.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/2/29.
//

#import "LGSportTrainItemCell.h"

#define width1  viewPix(72)
#define width2  viewPix(45)
#define width3  viewPix(100)
#define width4  viewPix(115)

@interface LGSportTrainItemCell()
/**   */
@property (nonatomic , strong)UIView *topLine;
/**   */
@property (nonatomic , strong)UIView *lineView1;
/**   */
@property (nonatomic , strong)UIView *lineView2;
/**   */
@property (nonatomic , strong)UIView *lineView3;
/**   */
@property (nonatomic , strong)UIView *lineView4;
/**   */
@property (nonatomic , strong)UIView *lineView5;
/**   */
@property (nonatomic , strong)UIView *lineView6;
/**   */
@property (nonatomic , strong)UIView *lineView7;
/**   */
@property (nonatomic , strong)UIView *lineView8;
/**  运动名 */
@property (nonatomic , strong)UILabel *titleLabel;
/**  用时 */
@property (nonatomic , strong)UILabel *timeLabel;
/**  心率达标 */
@property (nonatomic , strong)UILabel *xldbLabel;
/**  平均心率 */
@property (nonatomic , strong)UILabel *pjxlLabel;
/**  最大心率 */
@property (nonatomic , strong)UILabel *zdxlLabel;
/**  血压前 */
@property (nonatomic , strong)UILabel *xyqTitleLabel;
@property (nonatomic , strong)UILabel *xyqValueLabel;
@property (nonatomic , strong)UIImageView *xyqStatus;
/**  血压后 */
@property (nonatomic , strong)UILabel *xyhTitleLabel;
@property (nonatomic , strong)UILabel *xyhValueLabel;
@property (nonatomic , strong)UIImageView *xyhStatus;

/**  症状前 */
@property (nonatomic , strong)UILabel *zzqTitleLabel;
@property (nonatomic , strong)UILabel *zzqValueLabel;

/**  症状后 */
@property (nonatomic , strong)UILabel *zzhTitleLabel;
@property (nonatomic , strong)UILabel *zzhValueLabel;
/**  疲劳程度 */
@property (nonatomic , strong)UILabel *plcdLabel;
/**  呼吸困难 */
@property (nonatomic , strong)UILabel *hxknLabel;
/**   */
@property (nonatomic , strong)NSDictionary *xyStatusDic;

@end

@implementation LGSportTrainItemCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.xyStatusDic = @{@"":@"",@"up":@"运动记录-上升",@"down":@"运动记录-下降"};
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
    self.timeLabel.text = LGNSString(dataDic[@"yongs"]);
    self.xldbLabel.text = LGNSString(dataDic[@"xinldb"]);
    self.pjxlLabel.text = LGNSString(dataDic[@"pinjxl"]);
    self.zdxlLabel.text = LGNSString(dataDic[@"zuidxl"]);
    self.xyqValueLabel.text = (LGNSString(dataDic[@"xuey_before"][@"value"]).length>0)?LGNSString(dataDic[@"xuey_before"][@"value"]):@" ";
    NSString *xyqStatus = LGNSString(dataDic[@"xuey_before"][@"status"]);
    self.xyqStatus.image = [UIImage imageNamed:self.xyStatusDic[xyqStatus]];
    self.xyhValueLabel.text = LGNSString(dataDic[@"xuey_after"][@"value"]);
    NSString *xyhStatus = LGNSString(dataDic[@"xuey_after"][@"status"]);
    self.xyhStatus.image = [UIImage imageNamed:self.xyStatusDic[xyhStatus]];
    self.zzqValueLabel.text = (LGNSString(dataDic[@"zhenz_before"]).length>0)?LGNSString(dataDic[@"zhenz_before"]):@"无";
    self.zzhValueLabel.text = (LGNSString(dataDic[@"zhenz_after"]).length>0)?LGNSString(dataDic[@"zhenz_after"]):@"无";
    self.plcdLabel.text = (LGNSString(dataDic[@"pilcd"]).length>0)?LGNSString(dataDic[@"pilcd"]):@"无";
    self.hxknLabel.text = (LGNSString(dataDic[@"huxkncd"]).length>0)?LGNSString(dataDic[@"huxkncd"]):@"无";
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.topLine];
    [self.contentView addSubview:self.lineView1];
    [self.contentView addSubview:self.lineView2];
    [self.contentView addSubview:self.lineView3];
    [self.contentView addSubview:self.lineView4];
    [self.contentView addSubview:self.lineView5];
    [self.contentView addSubview:self.lineView6];
    [self.contentView addSubview:self.lineView7];
    [self.contentView addSubview:self.lineView8];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.xldbLabel];
    [self.contentView addSubview:self.pjxlLabel];
    [self.contentView addSubview:self.zdxlLabel];
    [self.contentView addSubview:self.xyqTitleLabel];
    [self.contentView addSubview:self.xyqValueLabel];
    [self.contentView addSubview:self.xyqStatus];
    [self.contentView addSubview:self.xyhTitleLabel];
    [self.contentView addSubview:self.xyhValueLabel];
    [self.contentView addSubview:self.xyhStatus];
    [self.contentView addSubview:self.zzqTitleLabel];
    [self.contentView addSubview:self.zzqValueLabel];
    [self.contentView addSubview:self.zzhTitleLabel];
    [self.contentView addSubview:self.zzhValueLabel];
    [self.contentView addSubview:self.plcdLabel];
    [self.contentView addSubview:self.hxknLabel];
    [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);
        make.height.equalTo(@(0.5));
    }];
    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(width1);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView1.mas_right).offset(width1);
    }];
    [self.lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView2.mas_right).offset(width1);
    }];
    [self.lineView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView3.mas_right).offset(width2);
    }];
    [self.lineView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView4.mas_right).offset(width2);
    }];
    [self.lineView6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView5.mas_right).offset(width3);
    }];
    [self.lineView7 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView6.mas_right).offset(width4);
    }];
    [self.lineView8 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView7.mas_right).offset(width2);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(viewPix(10));
        make.right.equalTo(self.lineView1.mas_left).offset(-viewPix(10));
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.lineView1).offset(viewPix(10));
        make.right.equalTo(self.lineView2.mas_left).offset(-viewPix(10));
    }];
    [self.xldbLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView2.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView3.mas_left).offset(-viewPix(10));
    }];
    [self.pjxlLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView3.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView4.mas_left).offset(-viewPix(10));
    }];
    [self.zdxlLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView4.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView5.mas_left).offset(-viewPix(10));
    }];
    [self.xyqTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(8));
        make.left.equalTo(self.lineView5.mas_right).offset(viewPix(10));
    }];
    [self.xyqValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.xyqTitleLabel.mas_right).offset(viewPix(5));
        make.right.equalTo(self.xyqStatus.mas_left).offset(-viewPix(3));
        make.centerY.equalTo(self.xyqTitleLabel);
    }];
    [self.xyqStatus mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.lineView6.mas_left).offset(-viewPix(10));
        make.centerY.equalTo(self.xyqTitleLabel);
        make.width.height.equalTo(@(viewPix(12)));
    }];
    [self.xyhTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.xyqTitleLabel.mas_bottom).offset(viewPix(6));
        make.left.equalTo(self.xyqTitleLabel);
    }];
    [self.xyhValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.xyqValueLabel);
        make.centerY.equalTo(self.xyhTitleLabel);
    }];
    [self.xyhStatus mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.width.height.equalTo(self.xyqStatus);
        make.centerY.equalTo(self.xyhTitleLabel);
    }];
    [self.zzqTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.xyqTitleLabel);
        make.left.equalTo(self.lineView6.mas_right).offset(viewPix(10));
    }];
    [self.zzqValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.zzhTitleLabel.mas_right).offset(viewPix(5));
        make.right.lessThanOrEqualTo(self.lineView7.mas_left).offset(-viewPix(10));
        make.top.equalTo(self.zzqTitleLabel);
    }];
    [self.zzhTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.zzqValueLabel.mas_bottom).offset(viewPix(6));
        make.left.equalTo(self.zzqTitleLabel);
    }];
    [self.zzhValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.zzqValueLabel);
        make.top.equalTo(self.zzhTitleLabel);
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
    }];
    [self.plcdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView7.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView8.mas_left).offset(-viewPix(10));
        make.centerY.equalTo(self.contentView);
    }];
    [self.hxknLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView8.mas_right).offset(viewPix(10));
        make.right.equalTo(self.contentView).offset(-viewPix(10));
        make.centerY.equalTo(self.contentView);
    }];
}


-(UIView *)topLine{
    if(!_topLine){
        _topLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_W-viewPix(32), 0.5)];
        _topLine.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _topLine;
}


-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:3];
    }
    return _titleLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}

-(UILabel *)xldbLabel{
    if(!_xldbLabel){
        _xldbLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _xldbLabel;
}

-(UILabel *)pjxlLabel{
    if(!_pjxlLabel){
        _pjxlLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _pjxlLabel;
}

-(UILabel *)zdxlLabel{
    if(!_zdxlLabel){
        _zdxlLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _zdxlLabel;
}

-(UILabel *)xyqTitleLabel{
    if(!_xyqTitleLabel){
        _xyqTitleLabel = [UILabel lableWithText:@"前" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _xyqTitleLabel;
}

-(UILabel *)xyqValueLabel{
    if(!_xyqValueLabel){
        _xyqValueLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _xyqValueLabel;
}

-(UIImageView *)xyqStatus{
    if(!_xyqStatus){
        _xyqStatus = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    }
    return _xyqStatus;
}

-(UILabel *)xyhTitleLabel{
    if(!_xyhTitleLabel){
        _xyhTitleLabel = [UILabel lableWithText:@"后" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _xyhTitleLabel;
}

-(UILabel *)xyhValueLabel{
    if(!_xyhValueLabel){
        _xyhValueLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _xyhValueLabel;
}

-(UIImageView *)xyhStatus{
    if(!_xyhStatus){
        _xyhStatus = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    }
    return _xyhStatus;
}

-(UILabel *)zzqTitleLabel{
    if(!_zzqTitleLabel){
        _zzqTitleLabel = [UILabel lableWithText:@"前" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _zzqTitleLabel;
}

-(UILabel *)zzqValueLabel{
    if(!_zzqValueLabel){
        _zzqValueLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _zzqValueLabel;
}


-(UILabel *)zzhTitleLabel{
    if(!_zzhTitleLabel){
        _zzhTitleLabel = [UILabel lableWithText:@"后" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _zzhTitleLabel;
}

-(UILabel *)zzhValueLabel{
    if(!_zzhValueLabel){
        _zzhValueLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _zzhValueLabel;
}


-(UILabel *)plcdLabel{
    if(!_plcdLabel){
        _plcdLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _plcdLabel;
}

-(UILabel *)hxknLabel{
    if(!_hxknLabel){
        _hxknLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _hxknLabel;
}


-(UIView *)lineView1{
    if(!_lineView1){
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView1;
}

-(UIView *)lineView2{
    if(!_lineView2){
        _lineView2 = [[UIView alloc] init];
        _lineView2.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView2;
}

-(UIView *)lineView3{
    if(!_lineView3){
        _lineView3 = [[UIView alloc] init];
        _lineView3.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView3;
}

-(UIView *)lineView4{
    if(!_lineView4){
        _lineView4 = [[UIView alloc] init];
        _lineView4.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView4;
}

-(UIView *)lineView5{
    if(!_lineView5){
        _lineView5 = [[UIView alloc] init];
        _lineView5.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView5;
}

-(UIView *)lineView6{
    if(!_lineView6){
        _lineView6 = [[UIView alloc] init];
        _lineView6.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView6;
}

-(UIView *)lineView7{
    if(!_lineView7){
        _lineView7 = [[UIView alloc] init];
        _lineView7.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView7;
}

-(UIView *)lineView8{
    if(!_lineView8){
        _lineView8 = [[UIView alloc] init];
        _lineView8.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView8;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
